import { Component } from "@xuekl/cli-core/enums"
import * as c from "@xuekl/cli-core/components"
import { BaseForm } from "@xuekl/cli-core/builder"
import { treeData } from "_/utils"

export default class Dept extends BaseForm {
    deptId = ''
    parentId = ''
    deptName = ''
    orderNum = 0
    leader = ''
    phone = ''
    email = ''
    status = '0'

    clear(): void {
        this.setForm(new Dept(this.opts))
        this.resetFields()
    }

    getParentId(): c.TreeSelect {
        return {
            type: Component.TreeSelect,
            label: '上级部门',
            required: true,
            span: 24,
            config: {
                url: '/system/dept/list',
                valueTarget: 'deptId',
                labelTarget: 'deptName',
                convertData: (data) => {
                    return treeData(data, 'deptId', 'parentId')
                }
            },
            element: {
                checkStrictly: true
            }
        }
    }

    getDeptName(): c.Input {
        return {
            type: Component.Input,
            label: '部门名称',
            mode: 'query',
            required: true,
            element: {
            }
        }
    }

    getOrderNum(): c.InputNumber {
        return {
            type: Component.InputNumber,
            label: '显示排序',
            required: true,
        }
    }

    getLeader(): c.Input {
        return {
            type: Component.Input,
            label: '负责人',
            element: {
            }
        }
    }

    getPhone(): c.Input {
        return {
            type: Component.Input,
            label: '联系电话',
            element: {
            }
        }
    }

    getEmail(): c.Input {
        return {
            type: Component.Input,
            label: '邮箱',
            element: {
            }
        }
    }

    getStatus(): c.Radio {
        return {
            type: Component.Radio,
            label: '部门状态',
            config: {
                dict: 'sys_normal_disable'
            }
        }
    }
}
